package com.itheima.zuoye.d02;

import java.util.Objects;

public class Cat {
//    1.创建Cat类（name,age,sex）
    private String name;
    private int age;
    private String sex;

    public Cat() {
    }

    public Cat(String name, int age, String sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Cat{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Cat cat = (Cat) o;
        return age == cat.age && Objects.equals(name, cat.name) && Objects.equals(sex, cat.sex);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, sex);
    }
}

